package com.yvon.maple.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author : Yvon
 * @since : 2022-03-04
 */
public enum UserTypeEnum {

    /**
     * 注册用户.
     */
    REGISTER("register", "注册用户"),

    /**
     * ldap用户.
     */
    LDAP("ldap", "ldap用户");


    /**
     * Code
     */
    @EnumValue
    private final String code;

    /**
     * Name
     */
    private final String message;


    /**
     * Message category.
     *
     * @param code the code
     * @param message the name
     */
    UserTypeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }



    /**
     * Get code string.
     *
     * @return {@link String }
     * @author : Yvon / 2021-08-26
     */
    @JsonValue
    public String getCode() {
        return code;
    }

    /**
     * Get message string.
     *
     * @return {@link String }
     * @author : Yvon / 2021-08-26
     */
    public String getMessage() {
        return message;
    }

    public static GenderEnum getByCode(Integer code){
        for (GenderEnum p : GenderEnum.values()) {
            if (code.equals(p.getCode())){
                return p;
            }
        }
        return null;
    }
}
